package com.burstly.lib.component.networkcomponent;

import com.burstly.lib.util.LoggerExt;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Map;

public abstract class AbstractNetworkConfigurator<T>
  implements INetworkConfigurator<T>
{
  private static final LoggerExt LOG = LoggerExt.getInstance();

  protected static Integer getAge(Date paramDate)
  {
    if (paramDate == null)
      return null;
    GregorianCalendar localGregorianCalendar = new GregorianCalendar();
    localGregorianCalendar.setTime(paramDate);
    int i = localGregorianCalendar.get(1);
    int j = 1 + localGregorianCalendar.get(2);
    int k = localGregorianCalendar.get(5);
    localGregorianCalendar.setTime(new Date());
    int m = localGregorianCalendar.get(1) - i;
    if ((j > localGregorianCalendar.get(2)) || ((j == localGregorianCalendar.get(2)) && (k > localGregorianCalendar.get(5))))
      m--;
    if (m < 0)
      throw new IllegalArgumentException("Age < 0");
    return Integer.valueOf(m);
  }

  private void logParameters()
  {
    try
    {
      Field[] arrayOfField = getClass().getDeclaredFields();
      String str1 = getClass().getSimpleName();
      LOG.logDebug(str1, "Parsed parameters:", new Object[0]);
      int i = arrayOfField.length;
      for (int j = 0; j < i; j++)
      {
        Field localField = arrayOfField[j];
        localField.setAccessible(true);
        String str2 = localField.getName();
        Object localObject = localField.get(this);
        if (!Modifier.isStatic(localField.getModifiers()))
          LOG.logDebug(str1, "{0}={1}", new Object[] { str2, localObject });
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  protected void applyClientTargetingIfAllowed(Map<String, ?> paramMap)
  {
    Map localMap = (Map)paramMap.get("clientTargetingParams");
    String str = (String)paramMap.get("rejectUserTargeting");
    if ((localMap != null) && (localMap.size() > 0) && (!"YES".equalsIgnoreCase(str)))
      applyClientTargetingParamsToNetwork(localMap);
  }

  protected abstract void applyClientTargetingParamsToNetwork(Map<String, String> paramMap);

  public abstract void configure(T paramT);

  public final void initConfigurator(Map<String, ?> paramMap)
    throws IllegalArgumentException
  {
    readParameters(paramMap);
    logParameters();
  }

  protected abstract void readParameters(Map<String, ?> paramMap)
    throws IllegalArgumentException;
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.AbstractNetworkConfigurator
 * JD-Core Version:    0.6.2
 */